$(function(){
    //用户获奖列表切换
    $(".usershow").slide({
        mainCell:".inner ul",
        effect:"leftLoop",
        vis:5,
        autoPlay:true,
        interTime:3000
    });
    $(".usershow .tempWrap").width('100%');
    //地图切换
    $(".map").slide({
        mainCell:".mapul",
        titCell:".dot ul",
        effect:"fold",
        mouseOverStop:false,
        autoPlay:true,
        autoPage:true,
        interTime:3000
    });
    //闪灯效果
    var timer = setInterval(function(){
        $('.lottery .light').toggleClass('show')
        $('.lottery .dot').toggleClass('show')
    },600)

    //活动规则
    $('.rulebtn.pc').click(function(){
        $('.pop_rule').show()
        $('.blackbg').show()
    });
    //弹窗关闭
    $('.pop_close').click(function(){
        $(this).parent().parent().hide()
        $('.blackbg').hide()
    });
    if($(window).width()>640){
        pageAnimate();//动画初始化
    }
});
$(window).scroll(function(){
    if($(window).width()>640){
        pageAnimate();
    }
});
function qrcodeShow(){
    var qrh = animateScroll("qrh"),
        aTop = $(window).scrollTop();
    if (aTop>(qrh)){
        $('.qrcode.pc').show();
    }else {
        $('.qrcode.pc').hide();
    }
}
function animateScroll(cenConId){
    var partId = $('#' + cenConId);
    //判断元素是否存在
    if (partId.length != 1){
        return false;
    }
    var offsetTop = arguments[1] ? arguments[1] : 0,
        cenHeight = partId.offset().top - $(window).height();
    return cenHeight;
}

function pageAnimate(){
    var	anibox1 = animateScroll("anibox1"),
        anibox2 = animateScroll("anibox2"),
        anibox3 = animateScroll("anibox3"),
        anibox4 = animateScroll("anibox4"),
        aTop = $(window).scrollTop();
    var hspan = 100;


    $(".ban_tit").animate({opacity:1,left:0},800);
    $(".lottery").delay(100).animate({opacity:1,marginLeft:0},800);

    if (aTop>(anibox1+hspan+50)){
        $(".part1 .title").eq(0).animate({opacity:1,top:0},800);
        $(".usershow").delay(300).animate({opacity:1,bottom:0},800);
        $(".step").delay(600).animate({opacity:1,bottom:0},800);
    }

    if (aTop>(anibox2+hspan+50)){
        $(".part2 .title").animate({opacity:1,top:0},800);
        $(".part2 .subtit").animate({opacity:1,bottom:0},800);
        $(".map").delay(300).animate({opacity:1,bottom:0},800);
        $(".part2 .btn_div").delay(600).animate({opacity:1,bottom:0},800);
    }
    if (aTop>(anibox3+hspan+50)){
        $(".part3 .title").animate({opacity:1,top:0},800);
        $(".easylist li").eq(0).animate({opacity:1,bottom:0},800);
        $(".easylist li").eq(1).delay(300).animate({opacity:1,bottom:0},800);
        $(".easylist li").eq(2).delay(600).animate({opacity:1,bottom:0},800);

    }
    if (aTop>(anibox4+hspan+50)){
        $(".part4 .title").animate({opacity:1,top:0},800);
        $(".part4 .subtit").animate({opacity:1,bottom:0},800);
        $(".yslist .ysbox").eq(0).delay(300).animate({opacity:1,left:0},800);
        $(".yslist .ysbox").eq(1).delay(300).animate({opacity:1,right:0},800);
        $(".yslist .add").delay(300).animate({opacity:1,bottom:0},800);
        $(".part4 .btn_div").delay(600).animate({opacity:1,bottom:0},800);
    }
}
$(document).ready(function(){
    activity.init();
});
var activity = {
    /***绑定事件***/
    init:function(){
        $(".lottery_btn b").on("click",this.rotate);
    },
    /**转动抽奖盘**/
    rotate:function(){  //awards:奖项,text:提示文字,剩余抽奖次数
        $('#lottery_cont').stopRotate();
        var angle=271;
        //转动
        $("#lottery_cont").rotate({
            angle:0,
            duration: 5000,
            animateTo: angle+1800,
            callback:function(){
                $('.pop_congra,.blackbg').show();
            }
        });
    }
};